<template>
  <div>
    <el-dialog :visible.sync="uploadDialog" title="结算上传" width="30%" center>
      <div style="display: flex;flex-direction: column;align-items: center">
      <div>
        <span>结算金额：<el-input size="small" style="width: 300px;margin-left: 10px" v-model="form.preSettlementMoney"></el-input></span>
      </div>
      <div style="margin-top: 20px;">
        <span style="width: 85px;display: inline-block;">供货商类型:</span>
        <el-select size="small" clearable
                   placeholder="请公司类型" style="width: 300px" v-model="form.type">
          <el-option v-for="item in companyList" :key="item.type" :label="item.name"
                     :value="item.type">
          </el-option>
        </el-select>
      </div>
      <div style="margin-top: 20px;">
        <span>
          结算单：
           <upload-excel
               v-if="uploadDialog"
               style="margin-top: 10px"
               :type="'结算单'"
               @addStatus="handleUploadSuccess"
           />
        </span>
      </div>
      </div>
      <span slot="footer">
        <el-button size="small" style="background-color:#eee;color: #666" @click="uploadDialog=false">取 消</el-button>
        <el-button size="small" style="background-color:#303e9d;color: #eeeeee" @click="_submit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import uploadExcel from "./uploadExcel.vue";

export default {
  name: "settlementUpload",
  components: {
    uploadExcel
  },
  data() {
    return {
      uploadDialog: false,
      companyList: [],
      form: {
        preSettlementMoney: "",
        preSettlementUrl: "",
        assignTaskId: "",
        type: null
      }
    }
  },
  created() {
    // this.getSupplierTypeInfo()
  },
  methods: {
    getSupplierTypeInfo() {
      this.$api.companyGetSupplierTypeInfo().then(res => {
        this.companyList = res
      })
    },
    handleOpen(row) {
      this.uploadDialog = true
      this.getSupplierTypeInfo()
      this.form = this.$options.data().form
      this.form.assignTaskId = row.assignTaskId
    },
    handleUploadSuccess(val) {
      if (val.type == '结算单') {
        this.form.preSettlementUrl = val.file
      }
    },
    _submit() {
      this.$api.budgetAddSupplierTaskSettlement(this.form).then(res => {
        if (res == 1) {
          this.uploadDialog = false
          this.$message.success("提交成功！")
          this.$emit("addStatus", 1);
        }
      })
    }
  }
}
</script>

<style scoped>
span {
  font-weight: bold;
}
</style>